import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtQuick.Dialogs 1.0
import QtQuick.Controls.Styles 1.0



Item {
    id: panelMenu

    property alias title: titleText.text
    property alias model: menuView.model
    property string hoverColor: "transparent"

    signal clickedIndex(int index);
    signal clickedText(string text);


    TitleText {
        id: titleText
        color: "white"
        
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right
    }


    
    ListView {
        id: menuView

        model: ListModel {}
        anchors.top: titleText.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        anchors.bottom: parent.bottom

        anchors.topMargin: 6
        anchors.leftMargin: 1;
        anchors.rightMargin: 1;

        spacing: 2
        
        delegate: Rectangle {

            height: 25
            anchors.left: parent.left
            anchors.right: parent.right
            
            border.width: 1
            border.color: "white"
            
            Label {
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 9
                color: "white"
                font.bold: true
                
                text: name
            }
            
            MouseArea {
                id: mouseArea
                hoverEnabled: true
                anchors.fill: parent
                onClicked: {
                    panelMenu.clickedIndex(index);
                    panelMenu.clickedText(name);
                }

            }
            
            color: mouseArea.containsMouse ? hoverColor : "transparent"
        }
        
    }

    height: model.count * 27 + titleText.height
}
